package com.finance.system.test.excute;

import com.finance.system.test.ListNode;
import com.finance.system.test.Solution;

public class Sum {

    public static void main(String[] args) {
        Solution solution = new Solution();
//        int[] l1val = new int[]{2,4,3};
//        int[] l2val = new int[]{5,6,4};
        int[] l1val = new int[]{5};
        int[] l2val = new int[]{5};

        ListNode l1 = createLink(l1val);
        ListNode l2 = createLink(l2val);

        ListNode listNode = solution.addTwoNumbers(l1, l2);

        System.out.println(listNode);
    }

    private static ListNode createLink(int[] vals) {
        ListNode ls = null;
        for (int val : vals) {
            ListNode listNode = new ListNode(val);
            if(ls == null){
                ls = listNode;
            }else{
                ListNode last = ListNode.findLast(ls);
                last.setNext(listNode);
            }
        }
        return ls;
    }


}
